home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / mini / LILO < prev    next >
Text File  |  1998-01-15  |  16KB  |  379 lines

  1.   Lilo mini-Howto
  2.   Cameron Spitzer (cls@truffula.sj.ca.us), Alessandro Rubini
  3.   (rubini@linux.it).
  4.   v2.1, 9 January 1998
  5.  
  6.   This file describes some typical LILO installations.  It's intended as
  7.   a supplement to the LILO User's Guide.  I think examples are informa¡
  8.   tive even if your setup isn't much like mine.  I hope this saves you
  9.   trouble. Since Lilo's own documentation is very good, who's interested
  10.   in the details is referred to /usr/doc/lilo*
  11.  
  12.   1.  Introduction
  13.  
  14.   Although the documentation found in Lilo's sources (the one installed
  15.   in /usr/doc/lilo-version) is very comprehensive, most Linux users can
  16.   find some difficulties in building their own /etc/lilo.conf file. This
  17.   document is meant to support them by giving the minimal information
  18.   and by showing five sample installations:
  19.  
  20.   ╖  The first example is the classical ``Linux and other''
  21.      installation.
  22.  
  23.   ╖  The next one shows how to install Lilo on a hard drive connected as
  24.      /dev/hdc that will boot as /dev/hda.  This is usually needed when
  25.      you install a new Linux drive from your own running system.
  26.  
  27.   ╖  The third example shows how to boot a Linux system whose root
  28.      partition can't be accessed by the BIOS.
  29.  
  30.   ╖  The next sample file is used to access huge disks, that neither the
  31.      BIOS nor DOS can access easily (this one is somehow outdated).
  32.  
  33.   ╖  The last example shows how to restore a damaged disk (the damage in
  34.      this case resulted from installing another operating system).
  35.  
  36.   The last three examples are by Cameron Spitzer, cls@truffula.sj.ca.us,
  37.   who wrote the original document. The current maintainer doesn't run
  38.   anything but Linux, so I can't check if nor update them.
  39.  
  40.   2.  Background Information and Standard Installation
  41.  
  42.   When Lilo boots the system, it can only load data sectors that can be
  43.   accessed by the bios. Any pathname you put in /etc/lilo.conf is
  44.   resolved at installation time (when you invoke lilo); this is when the
  45.   program builds any table listing which sectors are used by the files.
  46.   As a consequence, the files must live in a partition that can be
  47.   accessed by the BIOS; moreover, you must reinstall the loader (i.e.,
  48.   you must reinvoke lilo) any time you modify the files. Whenever you
  49.   recompile your kernel and overwrite your old image you must reinstall
  50.   Lilo).
  51.  
  52.   2.1.  Where Should I Install Lilo?
  53.  
  54.   The boot = directive in /etc/lilo.conf tells Lilo where it should put
  55.   its primary boot loader. In general, you can either specify the master
  56.   boot sector (/dev/hda) or the root partition of your Linux
  57.   installation (is usually is /dev/hda1 or /dev/hda2).
  58.  
  59.   If you have another operating system installed in your hard drive,
  60.   you'd better install Lilo to the root partition. In this case, you
  61.   must mark the partition as ``bootable'' (use the ``a'' command of
  62.   fdisk or the ``b'' command of cfdisk. If you don't overwrite the
  63.   master boot sector you'll find it easier to uninstall Linux and Lilo
  64.   if needed.
  65.  
  66.   2.2.  How Should I Configure my IDE Hard Drives?
  67.  
  68.   I personally don't use LBA or LARGE settings in the BIOS (but I only
  69.   run Linux); they are horrible kludges forced on by design deficiencies
  70.   in the PC world. This requires that the kernel lives in the first 1024
  71.   cylinders, but this is not a problem as long as you partition your
  72.   hard drives and keep root small (as you should do anyways).
  73.  
  74.   If your hard disk already carries another operating system, you won't
  75.   be able to modify the BIOS settings, or the old system won't work any
  76.   more. All recent Lilo distribution are able to deal with LBA and LARGE
  77.   disk settings.
  78.  
  79.   If you have more than one hard disk and some of them are only used by
  80.   Linux, but are not used in booting, you can tell your BIOS that they
  81.   are not installed. Your system will boot more quickly and Linux will
  82.   autodetect all the disk in no time. I often connect extra disks to my
  83.   system, but I never touch the BIOS configuration.
  84.  
  85.   2.3.  How Can I Interact at Boot Time?
  86.  
  87.   When you see the Lilo prompt, you can hit the <Tab> key to show the
  88.   list of possible choices. If Lilo is not configured to be interactive,
  89.   press and hold the <Alt> or <Shift> key before the ``LILO'' message
  90.   appears.
  91.  
  92.   If you choose to boot a Linux kernel, you can add command-line
  93.   arguments after the name of the system you choose. The kernel accepts
  94.   many command-line arguments, and this is not the place to list them
  95.   all. A few of them are particularly important, in my opinion:
  96.  
  97.   ╖  root=: you can tell the Linux kernel to mount as root a different
  98.      partition from the one appearing in lilo.conf.  For example, I have
  99.      a tiny partition hosting a minimal Linux installation, and I've
  100.      been able to boot the system after destroying my root partition by
  101.      mistake.
  102.  
  103.   ╖  init=: verson 1.3.43 and newer of the Linux kernel accept the
  104.      command-line specification of a program to execute in place of
  105.      /sbin/init. If you experience bad problems during the boot process,
  106.      you can access the bare system by specifying init=/bin/sh (when you
  107.      are at the shell prompt you most likely will need to mount your
  108.      disks: try ``/sbin/mount -w -n -o remount /; mount -a'', and
  109.      remember to ``/sbin/umount -a'' before turning off the computer).
  110.  
  111.   ╖  A number: specifying a number on the kernel command line you
  112.      instruct init to enter a specific run-level (the default is usually
  113.      3). Refer to the init documentation, to /etc/inittab and to
  114.      /etc/rc.d to probe further.
  115.  
  116.   2.4.  How Can I Uninstall Lilo?
  117.  
  118.   When Lilo overwrites a boot sector, it saves a backup copy in
  119.   /boot/boot.xxyy, where xxyy are the major and minor numbers of the
  120.   device, in hex. You can see the major and minor numbers of your disk
  121.   or partition by running ``ls -l /dev/device''. For example, the first
  122.   sector of /dev/hda (major 3, minor 0) will be saved in
  123.   /boot/boot.0300, installing Lilo on /dev/fd0 creates /boot/boot.0200
  124.   and installing on /dev/sdb3 (major 8, minor 19) creates
  125.   /boot/boot.0813. Note that Lilo won't create the file if there is
  126.   already one; you don't need to care about the backup copy whenever you
  127.   reinstall Lilo (for example, after recompiling your kernel).
  128.  
  129.   If you ever need to uninstall Lilo (for example, in the unfortunate
  130.   case you need to uninstall Linux), you just need to restore the
  131.   original boot sector. If Lilo is installed in /dev/hda, just do ``dd
  132.   if=/boot/boot.0300 of=/dev/hda bs=446 count=1'' (I personally just do
  133.   ``cat /boot/boot.0300 > /dev/hda'', but this is not safe, as this will
  134.   restore the original partition table as well, which you might have
  135.   modified in the meanwhile). This command is much easier to run than
  136.   trying ``fdisk /mbr'' from a DOS shell: it allows you to cleanly
  137.   remove Linux from a disk without ever booting anything else. After
  138.   removing Lilo remember to run Linux' fdisk to destroy any Linux
  139.   partition (DOS' fdisk is unable to remove non-dos partitions).
  140.  
  141.   If you installed Lilo on your root partition (e.g., /dev/hda2),
  142.   nothing special needs to be done to uninstall Lilo.  Just run Linux'
  143.   fdisk to remove Linux partitions from the partition table. You must
  144.   also mark the DOS partition as bootable.
  145.  
  146.   3.  The Simple Configuration
  147.  
  148.   Most Lilo installations use a configuration file like the following
  149.   one:
  150.  
  151.   boot = /dev/hda   # or your root partition
  152.   delay = 0         # or specify a delay in tenth of a second
  153.   vga = 0           # optional. Use "vga=1" to get 80x50
  154.  
  155.   image = /boot/vmlinux  # your zImage file
  156.     root = /dev/hda1     # your root partition
  157.     label = Linux        # or any fancy name
  158.     read-only            # mount root read-only
  159.  
  160.   other = /dev/hda4   # your dos partition, if any
  161.     table = /dev/hda  # the current partition table
  162.     label = dos       # or any non-fancy name
  163.  
  164.   You can multiple ``image'' and ``other'' sections if you want. It's
  165.   not uncommon to have several kernel images configured in your
  166.   lilo.conf, at least if you keep up to dat with the developers.
  167.  
  168.   4.  Installing hdc to boot as hda
  169.  
  170.   Lilo allows to map the kernel image from one disk and instruct the
  171.   BIOS to retrieve it from another disk. For example, it's common for me
  172.   to install Linux on a disk I connect to hdc (master disk of secondary
  173.   controller) and boot it as a standalong system on the primary IDE
  174.   controller of another computer. I copied the installation floppy to a
  175.   tiny partition, so I can run chroot in a virtual console to install
  176.   hdc while I use the system to do something else.
  177.  
  178.   The lilo.conf file I use to install Lilo looks like:
  179.  
  180.   # This file must be used from a system running from /dev/hdc
  181.   boot = /dev/hdc   # overwrite MBR of hdc
  182.   disk = /dev/hdc   # tell how hdc will look like:
  183.      bios = 0x80    #  the bios will see it as first drive
  184.   delay = 0
  185.   vga = 0
  186.  
  187.   image = /boot/vmlinux  # root partition is /dev/hdc1
  188.     root = /dev/hda1         # hdc1 at boot will be hda1
  189.     label = Linux
  190.     read-only
  191.  
  192.   This configuration file must be read by a Lilo running off /dev/hdc1.
  193.   The Lilo maps that get written the boot sector (/dev/hdc) must rever
  194.   the copies of vmlinux and to /boot/boot.b  that will be available at
  195.   boot time, i.e., the copies in hdc.
  196.  
  197.   I call this configuration file /mnt/etc/lilo.conf.hdc and I install
  198.   Lilo by invoking ``cd /mnt; chroot . sbin/lilo -C /etc/lilo.conf.hdc''
  199.   while /dev/hdc1 is mounted under /mnt.
  200.  
  201.   5.  Using Lilo When the BIOS Can't See the Root Partition
  202.  
  203.   I have two IDE drives, and a SCSI drive.  The SCSI drive can't be seen
  204.   from BIOS.  The Linux Loader, Lilo, uses BIOS calls and can only see
  205.   drives that BIOS can see.  My stupid AMI BIOS will only boot from "A:"
  206.   or "C:" My root file system is on a partition on the SCSI drive.
  207.  
  208.   The solution consists in storing the kernel, map file, and chain
  209.   loader in a Linux partition on the first IDE.  Notice that it is not
  210.   necessary to keep your kernel on your root partition.
  211.  
  212.   The second partition on my first IDE (/dev/hda2, the Linux partition
  213.   used to boot the system) is mounted on /u2.  Here is the
  214.   /etc/lilo.conf file I used.
  215.  
  216.   #  Install LILO on the Master Boot Record
  217.   #  on the first IDE.
  218.   #
  219.   boot = /dev/hda
  220.   #  /sbin/lilo (the installer) copies the LILO boot record
  221.   #  from the following file to the MBR location.
  222.   install = /u2/etc/lilo/boot.b
  223.   #
  224.   #  I wrote a verbose boot menu.  LILO finds it here.
  225.   message = /u2/etc/lilo/message
  226.   #  The installer will build the following file. It tells
  227.   #  the boot-loader where the blocks of the kernels are.
  228.   map = /u2/etc/lilo/map
  229.   compact
  230.   prompt
  231.   #  Wait 10 seconds, then boot the 1.2.1 kernel by default.
  232.   timeout = 100
  233.   #  The kernel is stored where BIOS can see it by doing this:
  234.   #      cp -p /usr/src/linux/arch/i386/boot/zImage /u2/z1.2.1
  235.   image = /u2/z1.2.1
  236.           label = 1.2.1
  237.   #  LILO tells the kernel to mount the first SCSI partition
  238.   #  as root.  BIOS does not have to be able to see it.
  239.           root = /dev/sda1
  240.   #  This partition will be checked and remounted by /etc/rc.d/rc.S
  241.           read-only
  242.   #  I kept an old Slackware kernel lying around in case I built a
  243.   #  kernel that doesn't work.  I actually needed this once.
  244.   image = /u2/z1.0.9
  245.           label = 1.0.9
  246.           root = /dev/sda1
  247.           read-only
  248.   #  My DR-DOS 6 partition.
  249.   other = /dev/hda1
  250.           loader=/u2/etc/lilo/chain.b
  251.           label = dos
  252.           alias = m
  253.  
  254.   6.  Accessing Huge Disks When the BIOS Can't
  255.  
  256.   The system in my office has a 1GB IDE drive.  The BIOS can only see
  257.   the first 504 MB of the IDE.  (Where MB means 2**10 bytes, not 10**6
  258.   bytes.)  So I have MS-DOS on a 350 MB partition /dev/hda1 and my Linux
  259.   root on a 120 MB partition /dev/hda2.
  260.  
  261.   MS-DOS was unable to install itself correctly when the drive was
  262.   fresh.  Novell DOS 7 had the same problem.  Luckily for me, "Options
  263.   by IBM" forgot to put the "OnTrack" diskette in the box with the
  264.   drive.  The drive was supposed to come with a product called "OnTrack
  265.   Disk Manager."  If you only have MSDOS, I guess you have to use it.
  266.  
  267.   So I made a partition table with Linux' fdisk.  MSDOS-6.2 refused to
  268.   install itself in /dev/hda1.  It said something like ``this release of
  269.   MS-DOS is for new installations.  Your computer already has MS-DOS so
  270.   you need to get an upgrade release from your dealer.''  Actually, the
  271.   disk was brand new.
  272.  
  273.   What a crock!  So I ran Linux' fdisk again and deleted partition 1
  274.   from the table.  This satisfied MS-DOS 6.2 which proceeded to create
  275.   the exact same partition 1 I had just deleted and installed itself.
  276.   MS-DOS 6.2 wrote its Master Boot Record on the drive, but it couldn't
  277.   boot.
  278.  
  279.   Luckily I had a Slackware kernel on floppy (made by the Slackware
  280.   installation program "setup"), so I booted Linux and wrote LILO over
  281.   MS-DOS' broken MBR.  This works.  Here is the /etc/lilo.conf file I
  282.   used:
  283.  
  284.   boot = /dev/hda
  285.   map = /lilo-map
  286.   delay = 100
  287.   ramdisk = 0             # Turns off ramdisk in Slackware kernel
  288.   timeout = 100
  289.   prompt
  290.   disk = /dev/hda         # BIOS only sees first 500 MB.
  291.      bios = 0x80          # specifies the first IDE.
  292.      sectors = 63         # get the numbers from your drive's docs.
  293.      heads = 16
  294.      cylinders = 2100
  295.   image = /vmlinuz
  296.     append = "hd=2100,16,63"
  297.     root = /dev/hda2
  298.     label = linux
  299.     read-only
  300.     vga = extended
  301.   other = /dev/hda1
  302.     label = msdos
  303.     table = /dev/hda
  304.     loader = /boot/chain.b
  305.  
  306.   After I installed these systems, I verified that the partition
  307.   containing the zImage, boot.b, map, chain.b, and message files can use
  308.   an msdos file system, as long as it is not "stackered" or
  309.   "doublespaced."  So I could have made the DOS partition on /dev/hda1
  310.   500 MB.
  311.  
  312.   I have also learned that "OnTrack" would have written a partition
  313.   table starting a few dozen bytes into the drive, instead of at the
  314.   beginning, and it is possible to hack the Linux IDE driver to work
  315.   around this problem.  But installing would have been impossible with
  316.   the precompiled Slackware kernel.  Eventually, IBM sent me an
  317.   "OnTrack" diskette.  I called OnTrack's technical support.  They told
  318.   me Linux is broken because Linux doesn't use BIOS.  I gave their
  319.   diskette away.
  320.  
  321.   7.  Booting from a Rescue Floppy
  322.  
  323.   Next, I installed Windows-95 on my office system.  It blew away my
  324.   nice LILO MBR, but it left my Linux partitions alone.  Kernels take a
  325.   long time to load from floppy, so I made a floppy with a working LILO
  326.   setup on it, which could boot my kernel from the IDE.
  327.  
  328.   I made the lilo floppy like so:
  329.  
  330.     fdformat /dev/fd0H1440      #  lay tracks on virgin diskette
  331.     mkfs -t minix /dev/fd0 1440 #  make file system of type minix
  332.     mount /dev/fd0 /mnt         #  mount in the standard tmp mount point
  333.     cp -p /boot/chain.b /mnt    #  copy the chain loader over
  334.     lilo -C /etc/lilo.flop      #  install LILO and the map on the diskette.
  335.     umount /mnt
  336.  
  337.   Notice that the diskette must be mounted when you run the installer so
  338.   that Lilo can write its map file properly.
  339.   This file is /etc/lilo.flop.  It's almost the same as the last one:
  340.  
  341.   #  Makes a floppy that can boot kernels from HD.
  342.   boot = /dev/fd0
  343.   map = /mnt/lilo-map
  344.   delay = 100
  345.   ramdisk = 0
  346.   timeout = 100
  347.   prompt
  348.   disk = /dev/hda     # 1 GB IDE, BIOS only sees first 500 MB.
  349.      bios=0x80
  350.      sectors = 63
  351.      heads = 16
  352.      cylinders = 2100
  353.   image = /vmlinuz
  354.     append = "hd=2100,16,63"
  355.     root = /dev/hda2
  356.     label = linux
  357.     read-only
  358.     vga = extended
  359.   other = /dev/hda1
  360.     label = msdos
  361.     table = /dev/hda
  362.     loader = /mnt/chain.b
  363.  
  364.   Finally, I needed MS-DOS 6.2 on my office system, but I didn't want to
  365.   touch the first drive.  I added a SCSI controller and drive, made an
  366.   msdos file system on it with Linux' mkdosfs, and Windows-95 sees it as
  367.   "D:".   But of course MSDOS will not boot off of D:.  This is not a
  368.   problem when you have LILO.  I added the following to the lilo.conf in
  369.   Example 2.
  370.  
  371.   other = /dev/sda1
  372.     label = d6.2
  373.     table = /dev/sda
  374.     loader = /boot/any_d.b
  375.  
  376.   With this modification MSDOS-6.2 runs, and it thinks it is on C: and
  377.   Windows-95 is on D:.
  378.  
  379.